<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

</body>
<script>
  //存储数据
  localStorage.setItem('id', 'value')
  //获取数据
  localStorage.getItem('id')
  console.log(localStorage.getItem('id'));

  let obj = { name: 'zs', age: 18 }
  //本地存储只能存储字符串 如果要存储复杂数据类型 先将对象转成字符串
  localStorage.setItem('obj', JSON.stringify(obj))
  console.log(JSON.parse(localStorage.getItem('obj')));

  //生命周期永久 除非手动删除 存储大小5M-10M
  localStorage.removeItem('obj')

</script>

</html>